<?php

/**
 * Announcement form.
 *
 * @package    cpfaizenay
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class AnnouncementForm extends BaseAnnouncementForm
{
  public function configure()
  {
     $user = sfContext::getInstance()->getUser()->getGuardUser();
      
     $dateWidget = new sfWidgetFormI18nDate(array(
      'format' => '%day%/%month%/%year%',
//      'month_format' => 'short_name',
      'culture' => 'fr'
    ));

    if ($this->isNew()) {
        $this->widgetSchema['updated_at'] = new sfWidgetFormInputHidden();
        $this->widgetSchema['modification_user_id'] = new sfWidgetFormInputHidden();

        $this->setDefault('creation_user_id', $user->getId());
        $this->setDefault('modification_user_id', $user->getId());

        $this->setDefault('created_at', date('d-m-Y') );
        $this->setDefault('updated_at', date('d-m-Y') );
    }else{
        $this->widgetSchema['updated_at'] = new sfWidgetFormJQueryDate(array(
          'culture' => 'fr',
          'date_widget' => $dateWidget,
          'image' => '/images/admin/icons/small/calendar.png',
          'config' => '{}',
        ));
        $this->getObject()->set('modification_user_id', $user->getId());
    }

    $this->widgetSchema['created_at'] = new sfWidgetFormJQueryDate(array(
      'culture' => 'fr',
      'date_widget' => $dateWidget,
      'image' => '/images/admin/icons/small/calendar.png',
      'config' => '{}',
    ));

    $this->widgetSchema['description'] = new sfWidgetFormTextareaTinyMCE(array(
          'width'  => 600,
          'height' => 350,
          'config'=> 'theme : "advanced",
                       language : "fr",
                       relative_urls : false,
                       cleanup : true,
                       plugins : "paste,table,advhr,advimage,advlink,emotions,preview,searchreplace,print,contextmenu,fullscreen,media",
                       theme_advanced_buttons1_add : "fontselect,fontsizeselect",
                       theme_advanced_buttons2_add : "media,zoom,forecolor,backcolor,separator,emotions,fullscreen",
                       theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect",
                       theme_advanced_buttons3 : "",
                       theme_advanced_disable : "help",
                       theme_advanced_toolbar_location : "top",
                       theme_advanced_toolbar_align : "left",
                       // theme_advanced_statusbar_location : "bottom",
                       // plugin_insertdate_dateFormat : "%d/%m/%Y",
                       // plugin_insertdate_timeFormat : "%H:%M:%S",
                       theme_advanced_resizing : true,
                       theme_advanced_resize_horizontal : false,
                       theme_advanced_resizing_use_cookie : false,
                       indentation : "10px"'
    ));
  }
}
